package com.ncloud.act.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ncloud.common.exception.UserException;
import com.ncloud.act.common.ActDataHelper;
import com.ncloud.act.entity.AccessLog;
import com.ncloud.act.mapper.AccessLogMapper;
import com.ncloud.act.service.AccessLogService;

@Service
public class AccessLogServiceImpl implements AccessLogService{
	@Resource
	private AccessLogMapper mapper;
	
	public JSONArray getAccessLogByAcctID(JSONObject json){
		if(!json.containsKey("acct_id"))
			throw new UserException("2001", "传入参数有误");
		Long acctID = json.getLong("acct_id");
		List<AccessLog> dicts = mapper.getAccessLogByAcctID(acctID);
		JSONArray results=JSON.parseArray(JSON.toJSONString(dicts));
		ActDataHelper.div100(results, new String[] { "old_balance","money", "new_balance"});
		return results;
	}
}
